<?php

$admin_pre_folder = "../../";

include '../../class.php';

$update['program_name'] = "'".$sql->escape($_POST['program_name'])."'";
$update['program_text'] = "'".$sql->escape($_POST['program_text'])."'";
$update['program_mintext'] = "'".$sql->escape($_POST['program_mintext'])."'";
$update['program_banner'] = "'".$sql->escape($_POST['program_banner'])."'";
$update['program_icon'] = "'".$sql->escape($_POST['program_icon'])."'";
$update['program_image'] = "'".$sql->escape($_POST['program_image'])."'";

$date = explode("-", $_POST['program_startdate']);
$update['program_startdate'] = mktime(0,0,0,$date[1],$date[2],$date[0]);

$update['program_link'] = "'".$sql->escape($_POST['program_link'])."'";
$update['program_link_light'] = "'".$sql->escape($_POST['program_link_light'])."'";
$update['program_reff'] = "'".$sql->escape($_POST['program_reff'])."'";
$update['program_payment'] = "';".implode(";", $_POST['program_payment']).";'";


if ($_POST['action']=="edit")
{
	$id = (int)$_POST['id'];
	
	if ($sql->mysql_update("programs", $update,"program_id = ".$id))
		$_SESSION['message']['highlight'][] = "Adatok sikeresen módosítva lettek az adatbázisban!";
}

if ($_POST['action']=="add")
{
	if ($sql->mysql_insert("programs", $update))
		$_SESSION['message']['highlight'][] = "Adatok sikeresen hozzá lettek adva!";
}

header("Location: ".$admin_pre_folder."index.php?".$_POST['module']);
?>